#![allow(non_snake_case)]
mod radio_group;
mod radio_item;

pub use radio_group::RadioGroup;
pub use radio_item::RadioItem;

use leptos::prelude::*;
use shq_common::prelude::Size;
use thaw_utils::{class_list, Model};
#[component]
pub fn Radio(
    #[prop(into)] name: String,
    #[prop(optional, into)] value: Model<bool>,
    #[prop(optional, into)] size: MaybeProp<Size>,
    #[prop(optional, into)] disabled: MaybeProp<bool>,
    #[prop(optional)] children: Option<Children>,
) -> impl IntoView {
    view! {
        <label class=class_list!["label cursor-pointer",size.get().unwrap_or_default().to_class("radio")] on:click=move |_| value.set(!value.get_untracked())>
            <input class="radio mr-1" name=name type="radio" checked=move || value.get() disabled=move||disabled.get()/>
            <span class="label-text">{children.map(|children| children())}</span>
        </label>
    }
}
